package yjpay.api.web.control;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import yjpay.service.PayAPIService;

/**
 * 绑卡支付支付结果查询
 * 
 * @author junqinghuang
 * 
 */
@Controller
public class QueryPayResultWebCtrl {
	@Resource(name = "payAPIService")
	private PayAPIService payAPIService;

	@RequestMapping(value = "/pay/to_query")
	public ModelAndView home() {
		// 返回信用卡支付页面
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("pay/query_pay_result.jsp");
		return modelAndView;
	}

	@RequestMapping(value = "/pay/query_order")
	public ModelAndView queryorder(Model model,
			@RequestParam("orderid") String orderid) throws Exception {

		String payresult = payAPIService.queryPay(orderid);

		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("pay/pay_result.jsp");
		modelAndView.addObject("apiname", "支付结果查询接口");
		modelAndView.addObject("payresult_view", payresult);

		return modelAndView;
	}
}
